package com.xiaoye.qbdatahandle.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

public class ListToJsonConverter implements Converter<List<Object>> {
    @Override
    public WriteCellData<?> convertToExcelData(List<Object> value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value == null) {
            return null;
        }
        return new WriteCellData<>(JSONArray.toJSONString(value));
    }
}
